JAVAC=$(JAVA_HOME)/bin/javac
JAVA=$(JAVA_HOME)/bin/java

JTTJAR=../jtokyotyrant.jar
JTTSO=../libjtokyotyrant.so

CLASSPATH=.:$(JTTJAR)
SRC=$(wildcard ./*.java)
CLS=$(wildcard ./*.class)

all: compile

check:
	@test -d "$(JAVA_HOME)" || (echo "Error:\n  JAVA_HOME is undefined." ; exit 1)
	@test -f $(JTTJAR)      || (echo "Error:\n  $(JTTJAR) is not found." ; exit 1)
	@test -f $(JTTSO)       || (echo "Error:\n  $(JTTSO) is not found."  ; exit 1)

compile: check $(SRC)
	$(JAVAC) -classpath $(CLASSPATH) $(SRC)	

run: check
	@test -n "$(CLSNAME)"   || (echo "Error:\n  CLSNAME is undefined." ; exit 1)
	$(JAVA) -classpath $(CLASSPATH) -Djava.library.path=../. $(CLSNAME)

clean:
	rm -rf *.class

.PHONY: all check compile run clean

